package com.tjetc.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
@Document(indexName = "detail")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Detail {
    @Id
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer id;
    @Field(type = FieldType.Text,store = true,index = true,analyzer = "ik_max_word")
    private String name;
    @Field(type = FieldType.Text,store = true,index = true)
    private String photo;
    @Field(type = FieldType.Double,store = true,index = true)
    private double price;
    @Field(type = FieldType.Text,store = true,index = true,analyzer = "ik_max_word")
    private String address;
    @Field(type = FieldType.Text,store = true,index = true,analyzer = "ik_max_word")
    private String type;
    @JsonFormat(pattern ="yyyy-MM-dd HH:mm",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @Field(type = FieldType.Text,store = true,index = true)
    private String time;

    public Detail(String name, String photo, double price, String address, String time) {
        this.name = name;
        this.photo = photo;
        this.price = price;
        this.address = address;
        this.time = time;
    }

    public Detail(Integer id, String name, String photo, double price, String address, String time) {
        this.id = id;
        this.name = name;
        this.photo = photo;
        this.price = price;
        this.address = address;
        this.time = time;
    }
}
